editors: add Cursor support and improve VSCode-like detection#291
editors: add Cursor support and improve VSCode-like detection#291ninyawee wants to merge 1 commit intobevry:masterfrom
Conversation
- Added new `is-cursor` command to detect Cursor editor - Created `is-vscode-like` command to generalize VSCode-like editor detection - Updated various commands to recognize Cursor alongside VSCode - Modified editor selection logic to include Cursor as a preferred editor
|
im not sure if this has to be in beta first. |
|
Cool, thank you. I'll review this properly after #281 is merged. |
There was a problem hiding this comment.
Todos before merging:
- Remove
is-vscode-like, change tois-vscode || is-cursor. - Do the minor changes.
- Document why the numerous checks in
is-cursorare necessary, if they indeed are. - Open an issue on Cursor's github requesting they change their
TERM_PROGRAMtocursorinstead ofvscode, link that created issue in a comment inis-vscode
| # Also check if we're in VSCode with Cursor-specific environment variables | ||
| if [[ ${TERM_PROGRAM-} == 'vscode' ]]; then | ||
| # Check for Cursor in environment variables | ||
| if env | grep -q "NAME=Cursor"; then |
There was a problem hiding this comment.
What is the point of these checks? Wouldn't it have been caught by the earlier ${NAME-} == "Cursor" check?
There was a problem hiding this comment.
But double conditioning is to make sure. Im not sure if name could be alter by others.
There was a problem hiding this comment.
Okay, let's remove this block then, and just do the earlier check. env will just reflect the current exported variables, which should be what is also shared by our current bash instance. For instance, if our bash instance changed NAME and it is exported, such a change will also happen for the called env. If NAME was no longer exported, same would occur for env. However, NAME could be a local variable, in addition to a parent's export variable, in this case, yes they could diverge, but is-cursor is running as a subshell command, so this should never be the case.
|
|
||
| function __check { | ||
| is-ci || is-vscode | ||
| is-ci || is-vscode-like |
There was a problem hiding this comment.
I think we nuke is-vscode-like and just change this to is-vscode || is-cursor, as it could be possible that a vscode-like editor comes out hat doesn't have title support, and this seems to be the only use case of such a vscode-like detection.
| # no terminal or gui preference, determine sensible defaults | ||
| if is-vscode; then | ||
| if is-cursor; then | ||
| editors+=(cursor) |
There was a problem hiding this comment.
missing # if running within Cursor, add Cursor as preference
| gui='yes' | ||
| terminal='yes' | ||
| elif is-vscode; then | ||
| # if running within vscode, add vscode as first preference |
There was a problem hiding this comment.
change comment to remove first
| done | ||
|
|
||
| if is-vscode; then | ||
| if is-vscode-like ; then |
There was a problem hiding this comment.
change to is-vscode || is-cursor
| @@ -0,0 +1,53 @@ | |||
| #!/usr/bin/env bash | |||
0403c8c to
38c051b
Compare
is-cursorcommand to detect Cursor editoris-vscode-likecommand to generalize VSCode-like editor detection